USE [codbsf]
GO

/****** Object:  Table [dbo].[orderItems]    Script Date: 12/08/2011 19:28:57 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[orderItems](
	[idOrderItem] [int] NOT NULL,
	[idOrder] [int] NOT NULL,
	[idProduct] [int] NOT NULL,
	[quantity] [int] NOT NULL,
	[pricePayed] [money] NULL,
 CONSTRAINT [PK_orderItems] PRIMARY KEY CLUSTERED 
(
	[idOrderItem] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[orderItems]  WITH CHECK ADD  CONSTRAINT [FK_orderItems_orders] FOREIGN KEY([idOrder])
REFERENCES [dbo].[orders] ([idOrder])
GO

ALTER TABLE [dbo].[orderItems] CHECK CONSTRAINT [FK_orderItems_orders]
GO

ALTER TABLE [dbo].[orderItems]  WITH CHECK ADD  CONSTRAINT [FK_orderItems_products] FOREIGN KEY([idProduct])
REFERENCES [dbo].[products] ([idProduct])
GO

ALTER TABLE [dbo].[orderItems] CHECK CONSTRAINT [FK_orderItems_products]
GO


